package cricket

import (
	"gorm.io/gorm/clause"
	"longmen/server/config/global"
	"longmen/server/pkg/db/mysql/models/models_sports"
)

type InsertCountryInterface interface {
	Get() models_sports.CricketCountry
}

func CrateCountry(a []InsertCountryInterface) {
	records := make([]models_sports.CricketCountry, 0)
	for _, c := range a {
		records = append(records, c.Get())
	}
	if len(records) == 0 {
		return
	}
	clauses := clause.OnConflict{
		UpdateAll: true,
	}
	err := global.Sport().Model(records).Clauses(clauses).CreateInBatches(records, 100).Error
	if err != nil {
		return
	}
}
